package com.karolak.stock.indicator;

import com.karolak.stock.data.DataManager;

public class LowTrInd extends Indicator {

	public LowTrInd(DataManager dataManager, int period, Indicator input) {
		super(dataManager, period, input);
		setName(String.format("%s%s", super.getName(), getInput().getName()));
	}

	public double execute(double x) {
		double lastInput = getDataManager().getLast(getInput().getName());
		double lastLow = getDataManager().getLast(getName());
		double last = lastInput < lastLow ? lastInput : lastLow;
		if (last == 0) {
			last = x;
		}
		return last;
	}
}
